<template>
	<IForm ref="form" :model="form" inline :label-width="60">
		<FormItem prop="phone" label="手机号" clearable>
			<IInput  placeholder="手机号" v-model="form.phone" ></IInput>
		</FormItem>
		<FormItem prop="time" label="发送时间" clearable>
			<DatePicker type="datetimerange" v-model="form.time" format="yyyy-MM-dd HH:mm" style="width: 300px" placeholder="发送时间"></DatePicker>
		</FormItem>
		<FormItem prop="status" label="发送状态">
			<Select v-model="form.status" clearable>
			    <Option v-for="item in status" :value="item.id" :key="item.id">{{ item.name }}</Option>
			</Select>
		</FormItem>
		<FormItem prop="isCheck" label="是否验证" v-model="form.isCheck">
			<Select  v-model="form.isCheck" clearable>
			    <Option v-for="item in checks" :value="item.id" :key="item.id">{{ item.name }}</Option>
			</Select>
		</FormItem>
		<FormItem>
			<IButton type="primary" @click="handleSubmit">筛选</IButton>
		</FormItem>
	</IForm>
</template>
<script>
import {Form,DatePicker,Input,Select, Option, OptionGroup,Button} from 'view-design';

export default{
	props:{
		callback:{type:Function}
	},
	components:{
		'IForm' : Form,
		'FormItem' : Form.Item,
        DatePicker,
        'IInput' : Input,
        Select,
        Option,
        'IButton' : Button,
    },
    data () {
        return {
        	form :{
        		phone : '',
        		time : '',
        		status : '',
        		isCheck : '',
        	},
        	status : [
    			{id : 0,name : '失败'},
    			{id : 1,name : '成功'}
    		],
    		checks : [
    			{id : 0,name : '否'},
    			{id : 1,name : '是'}
    		]
        }
    },
    methods: {
        handleSubmit() {
        	if(this.form.time[0]!=''){
        		var startTime = new Date(this.form.time[0]),
            		endTime = new Date(this.form.time[1]);
            	this.form['time'][0] = startTime.toLocaleDateString().replace(/\//g, "-") + " " + startTime.toTimeString().substr(0, 5);
            	this.form['time'][1] = endTime.toLocaleDateString().replace(/\//g, "-") + " " + endTime.toTimeString().substr(0, 5);
        	}
        	this.callback(this.form);
        }
    }
}
</script>